using System;
using System.Collections.Generic;
using System.Text;

namespace MCromwell.StaffIntranet.Core
{
    public class Administrator
    {
        private int id = -1;
        private Credentials credentials = null;

        public Administrator()
        {
        }

        public Administrator(Credentials credentials)
        {
            this.credentials = credentials;
        }

        public Administrator(int id, Credentials credentials)
            : this(credentials)
        {
            this.id = id;
        }
        
        internal virtual Credentials Credentials
        {
            get { return credentials; }
            set { credentials = value; }
        }

        public virtual int Id
        {
            get { return id; }
            internal set { id = value; }
        }

        public virtual string Username
        {
            get { return credentials.Username; }
        }
        
        public virtual bool AuthenticateAgainst(Credentials credentials)
        {
            // check against internal credentials
            // we could employ some strategy pattern
            // to have hash based password security
            return ((credentials.Username.Equals(this.credentials.Username, StringComparison.InvariantCultureIgnoreCase))
                        && (credentials.Password.Equals(this.credentials.Password, StringComparison.InvariantCultureIgnoreCase)));

        }

    }
}
